# !/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/5/7 14:11
# @Author  : qiaoc
# @File    : AuditRule.py
# @Desc    :

from examine.rule import AuditRuleEle
from examine.rule import AuditRuleWriteOff
from affix import AffixUtils
from dao.PyMysql import *


"""
    【综合票据稽核】 - 缴费单数据稽核
"""
def audit_rule_ele_data(audit_list, auditResult, bill_number, rar_file, whether_execute, audit_refused_type,result,
                     file_flag2, payment_electric_info_actual_reimbursement_amount, affix_list_from_db,
                     payment_detail_info_data, bill_table_ele_charge, current_share_ratio,rp_name,bill_table_uname,
                     all_file,file_flag3,execute_list, es_number,bill_table_data_electricity_price,current_reading,
                     bill_table_data,electricity_price,bill_table_data_list, rp_payment_start_time, rp_payment_end_time,
                     bill_table_start_date, bill_table_end_date,electricity_loss, ocr_electricity_loss,
                     electricity_consumption, bill_table_now_display_num,
                     electricity_consumption_list, bill_table_last_display_num, now_display_num, bill_table_total_power,last_reading, es_magnification,page_business_activities):

    """
    :param file_flag2:
    :param payment_electric_info_actual_reimbursement_amount:
    :param affix_list_from_db:
    :param payment_detail_info_data:
    :param bill_table_ele_charge:
    :param current_share_ratio:
    :param rp_name:
    :param bill_table_uname:
    :param all_file:
    :param file_flag3:
    :param execute_list:
    :param es_number:
    :param bill_table_data_electricity_price:
    :param current_reading:
    :param bill_table_data:
    :param electricity_price:
    :param bill_table_data_list:
    :param rp_payment_start_time:
    :param rp_payment_end_time:
    :param bill_table_start_date:
    :param bill_table_end_date:
    :param electricity_loss:
    :param ocr_electricity_loss:
    :param electricity_consumption:
    :param bill_table_now_display_num:
    :param electricity_consumption_list:
    :param bill_table_last_display_num:
    :param now_display_num:
    :param last_reading:
    :param es_magnification:
    :return:
    """

    # 规则一：页面【电表缴费明细信息】-【电表户号】查找附件二【用户编号】的【客户地址】与对应的页面【报账点名称】作匹对
    # ----   不一致：报账点名称与电力清单中名称不一致
    audit_list = AuditRuleEle.audit_rule_one(audit_list, rar_file, bill_number,
                   affix_list_from_db, bill_table_uname, file_flag2, rp_name)
    # 规则三：页面【实际报账金额】与附件2（以户号为依据）的金额判断，必须完全一致
    #       细化稽核规则：（1）报账点电费-铁塔电费：页面【实际报账金额】=附件2（以电表户号为依据）的金额*识别到的分摊比例，必须完全一致；
    #                   （2）报账点电费-自维电费：页面【实际报账金额】=附件2（以电表户号为依据）的金额*工单中录入的本次实际分摊比例，必须完全一致；
    # ----  不一致后动作：【审核状态】-【不通过】，备注：【实际报账金额】与【电费明细】不一致
    audit_list, auditResult,audit_refused_type = AuditRuleEle.audit_rule_three(audit_list, auditResult, bill_number, rar_file, whether_execute, audit_refused_type,
                     file_flag2, payment_electric_info_actual_reimbursement_amount, affix_list_from_db,
                     payment_detail_info_data, bill_table_ele_charge, current_share_ratio,
                     bill_table_data_list)
    # 规则五：页面【电费缴费明细信息】-【本次实际分摊比例】与附件3的【报账点名称】的【移动】（分摊比例）
    # ----   不一致后动作：【审核状态】-【不通过】，备注：系统中录入的分摊比例与附件不一致
    # ----   自维电费报账点不一致后动作：【审核状态】-【不通过】，备注：系统中录入的分摊比例不正确
    audit_list, auditResult,audit_refused_type = AuditRuleEle.audit_rule_five(auditResult, audit_list, whether_execute, bill_number, rar_file, audit_refused_type,
                    all_file, payment_detail_info_data, file_flag3, current_share_ratio, affix_list_from_db,
                    execute_list, es_number,page_business_activities)
    # 规则六：页面【电表缴费明细信息】-【本期读数（度）】与附件2根据页面【电表缴费明细信息】-【户号】查找对应的【本期指示】/【本月】等等
    # ----   不一致后动作：【审核状态】-【不通过】，备注：本期读数与电费明细不一致
    audit_list, auditResult,audit_refused_type = AuditRuleEle.audit_rule_six(audit_list, auditResult, rar_file, whether_execute, bill_number, audit_refused_type,
                   affix_list_from_db,
                   payment_detail_info_data, current_reading, file_flag2, bill_table_data, bill_table_data_list)

    # 规则十四：页面【电表缴费明细信息】-【本期读数（度）】与附件2根据页面【电表缴费明细信息】-【户号】查找对应的【上期指示】/【本月】等等
    # ----   不一致后动作：【审核状态】-【不通过】，备注：上期读数与电费明细不一致
    audit_list, auditResult, audit_refused_type = AuditRuleEle.audit_rule_fourteen(audit_list, auditResult, rar_file,
                                                                              whether_execute, bill_number,
                                                                              audit_refused_type,
                                                                              affix_list_from_db,
                                                                              payment_detail_info_data, last_reading,
                                                                              file_flag2, bill_table_data,
                                                                              bill_table_data_list)

    # 规则七：页面【电表缴费明细信息】-【电费单价（元/度）】与附件2根据页面【电表缴费明细信息】-【户号】查找对应的【电价】/【电费信息】之和等等
    # ----   不一致后动作：【审核状态】-【不通过】，备注：电费单价与电费明细不一致
    audit_list, auditResult,audit_refused_type = AuditRuleEle.audit_rule_seven(audit_list, auditResult, whether_execute, rar_file, affix_list_from_db, bill_number,
                     audit_refused_type,
                     file_flag2, payment_detail_info_data, bill_table_data_electricity_price,
                     electricity_price, bill_table_data_list)
    # 规则八：如果【本期读数】判断通过：页面【电表缴费明细信息】-【用电量（度）】=（【本期读数（度）】减去【上期读数（度）】）* 电表倍率 * 本次实际分摊比例（取页面的分摊比例），此条规则需完全一致。
    #        如果附件2无【本期读数】：页面【电表缴费明细信息】-【用电量（度）】+（【电损电量】/【本次实际分摊比例】（取页面的分摊比例））=附件2根据页面【电表缴费明细信息】-【户号】查找对应的【总结算电量】，
    #        总电量不包含电损的情况：页面【电表缴费明细信息】-【用电量（度）】=附件2根据页面【电表缴费明细信息】-【户号】查找对应的【电量】 * 本次实际分摊比例（取页面的分摊比例）。
    #        具体是那种情况，需在票据学习时区分附件2中电量是否包括电损。
    #        后面2条规则四舍五入匹配，相差±1度均可判断通过。
    # ----   不一致后动作：【审核状态】-【不通过】，备注：用电量与电费明细不一致
    audit_list, auditResult,audit_refused_type = AuditRuleEle.audit_rule_eight(auditResult, audit_list, audit_refused_type, whether_execute, rar_file, bill_number,
                     file_flag2,
                     electricity_consumption, affix_list_from_db, bill_table_now_display_num,
                     ocr_electricity_loss,
                     payment_detail_info_data, now_display_num, last_reading, es_magnification,
                     current_share_ratio,
                     electricity_consumption_list, bill_table_last_display_num, bill_table_data_list)
    # 规则九：前提：本次分摊比例稽核正确：页面【电表缴费明细信息】-【电损电量（度）】与附件2（有单独列出电损电量）：页面【电表缴费明细信息】-【电损电量（度）】=【本次实际分摊比例】*附件2的【电损值】；
    #        如附件2中同时有总电量（包括电损）、上期读数和本期读数，则页面【电表缴费明细信息】-【电损电量（度）】=【本次实际分摊比例】*（附件2的【总电量】-附件2【本期读数-上期读数】）。
    #        如果附件2（不符合上面情况或无单独列出电损电量）直接跳过。具体是那种情况，需在票据学习时区分附件2中电量是否包括电损。四舍五入匹配，相差±1度均可判断通过。
    # ----   不一致后动作：【审核状态】-【不通过】，备注：电损电量与电费明细不一致
    audit_list, auditResult,audit_refused_type = AuditRuleEle.audit_rule_nine(audit_list, auditResult, audit_refused_type, rar_file, result, whether_execute, bill_number,
                    now_display_num,bill_table_last_display_num,bill_table_total_power,es_magnification,
                    affix_list_from_db,
                    payment_detail_info_data, file_flag2, electricity_loss, ocr_electricity_loss,
                    current_share_ratio, bill_table_data_list)

    # 规则十：页面【报账点缴费信息】的【缴费期始】和【缴费期终】=附件2根据页面【电表缴费明细信息】-【户号】查找对应的【时间】/【起止时间】，如果附件2没有时间字段不作比对
    # ----   不一致后动作：【审核状态】-【不通过】，备注：缴费期始/终与电费明细不一致
    audit_list, auditResult,audit_refused_type = AuditRuleEle.audit_rule_ten(auditResult, audit_list, whether_execute, rar_file, bill_number, affix_list_from_db,
                   audit_refused_type,
                   file_flag2, payment_detail_info_data, rp_payment_start_time, rp_payment_end_time,
                   bill_table_start_date, bill_table_end_date, bill_table_data_list)

    return audit_list, auditResult,audit_refused_type

"""
    【综合票据稽核】 - 缴费单页面稽核
"""
def audit_rule_ele_page(auditResult, audit_list, bill_number, result,audit_refused_type,
                      payment_electric_info_actual_reimbursement_amount, rp_payment_info_actual_total_pc,
                      actual_nae_taxsad, actual_ef_tariff, actual_reimbursement_amount,whether_execute,
                      payment_detail_info_data, electricity_loss, share_degrees,
                      payment_benchmark_info_data, all_file, affix_list_from_db, floder_path, es_number):

    # 规则十一：增加“平均电费单价”展示，计算公式为：平均电费单价=【实际报账金额】/【实际总耗电量】，如此值小于等于0.3或者大于等于0.7，转人工稽核。其他稽核条件均需识别判断展示。
    #         备注：均电费单价小于等于0.3/大于等于0.7
    audit_list, auditResult = AuditRuleEle.audit_rule_eleven(auditResult, audit_list, bill_number, result,
                      payment_electric_info_actual_reimbursement_amount, rp_payment_info_actual_total_pc)

    # 规则二：页面【报账点缴费信息】-【实际不含税电费金额】+【实际电费税金】+【其他费用】的【含税金额】=【实际报账金额】
    # ----  不一致后动作：【审核状态】-【不通过】，备注：【实际不含税电费金额】+【实际电费税金】+【其他费用】的【含税金额】不等于【实际报账金额】
    audit_list, auditResult, audit_refused_type = AuditRuleEle.audit_rule_two(auditResult, audit_list, audit_refused_type, bill_number,
                   payment_electric_info_actual_reimbursement_amount,
                   actual_nae_taxsad, actual_ef_tariff, actual_reimbursement_amount)
    # 规则十二：增加“电损电量占比”展示，计算公式为：电损电量占比=【电损电量(度)】/【分摊后度数(度)】，如此值大于等于10%，转人工稽核。其他稽核条件均需识别判断展示。
    #          备注：电损电量占比大于等于10%
    audit_list, auditResult = AuditRuleEle.audit_rule_twelve(auditResult, audit_list, bill_number, whether_execute,
                      payment_detail_info_data, electricity_loss, share_degrees)
    # 规则四：页面【缴费标杆信息】-【标杆类型】（七类）-其中一类高于阈值（后期配置）为异常。目前为五类，预留两类，分别为智能电表标杆和动环负载标杆。
    # ----   先判断“是否超标（超标类型）”内容是否是“高于上限”，是则继续，“额定功率标杆”类型则判断超标率是否大于0%，其他类型则判断超标率是否大于20%
    # ----   异常后动作：检查是否存在附件5；如果附件5为单站，直接跳过（只需判断是否存在附件5）；如果附件5为汇总，进入附件6（excel）查找是否该户号；
    # ----             如果附件存在转人工（把所有的核对点都做了），如果附件不存在：【审核状态】-【不通过】，备注：请上传超标情况分析报告
    audit_list, auditResult,audit_refused_type = AuditRuleEle.audit_rule_four(auditResult, audit_list, bill_number, audit_refused_type,
                    payment_benchmark_info_data, all_file, affix_list_from_db, floder_path, es_number)

    return audit_list, auditResult, audit_refused_type



"""
    缴费单-查找不到附件数据的稽核处理：
"""
def audit_rule_ele_no_data(auditResult,audit_list,rar_file,bill_number,affix_list_from_db,whether_execute,audit_refused_type,
                        rp_name,payment_electric_info_actual_reimbursement_amount,current_reading,electricity_consumption,
                       payment_detail_info_data,rp_payment_start_time,rp_payment_end_time,electricity_price,electricity_loss,
                       current_share_ratio,file_flag2,file_flag3,all_file,execute_list,es_number):

    """
    :param rp_name: 报账点名称
    :param payment_electric_info_actual_reimbursement_amount: 实际报账金额
    :param current_reading: 本期读数
    :param electricity_consumption: 电表倍率
    :param payment_detail_info_data: 电表信息
    :param rp_payment_start_time: 期始
    :param rp_payment_end_time:期终
    :param electricity_price: 单价
    :param electricity_loss: 电损
    :param current_share_ratio: 分摊比例
    :param file_flag2: 附件2是否存在
    :param file_flag3: 附件3是否存在
    :param all_file:文件信息
    :param execute_list:
    :param es_number: 户号
    :return:
    """

    auditResult.auditStatus = '审核中'  # 返回稽核结果为转人工
    if '附件2' in rar_file:
        audit_list.append([str(bill_number), '报账点名称', str(rp_name), '', '0', 'RPA', '附件2文件格式不正确',
                           AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
        audit_list.append(
            [str(bill_number), '缴费期', str(rp_payment_start_time) + ',' + str(rp_payment_end_time), '', '0', 'RPA',
             '附件2文件格式不正确', AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])

        if whether_execute == False:
            audit_list.append(
                [str(bill_number), '实际报账金额', str(payment_electric_info_actual_reimbursement_amount), '', '0', 'RPA',
                 '附件2文件格式不正确', AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
            audit_list.append([str(bill_number), '本期读数', str(current_reading), '', '0', 'RPA', '附件2文件格式不正确',
                               AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
            audit_list.append([str(bill_number), '电费单价', str(electricity_price), '', '0', 'RPA', '附件2文件格式不正确',
                               AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
            audit_list.append([str(bill_number), '用电量', str(electricity_consumption), '', '0', 'RPA', '附件2文件格式不正确',
                               AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
            audit_list.append([str(bill_number), '电损电量', str(electricity_loss), '', '0', 'RPA', '附件2文件格式不正确',
                               AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
        else:
            for data in payment_detail_info_data:
                audit_list.append([str(bill_number), '实际报账金额', '(' + str(data['es_number']) + ')' + str(
                    payment_electric_info_actual_reimbursement_amount), '', '0', 'RPA', '附件2文件格式不正确',
                                   AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
                audit_list.append(
                    [str(bill_number), '本期读数', '(' + str(data['es_number']) + ')' + str(data['current_reading']), '',
                     '0', 'RPA', '附件2文件格式不正确', AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
                audit_list.append(
                    [str(bill_number), '电费单价', '(' + str(data['es_number']) + ')' + str(data['electricity_price']), '',
                     '0', 'RPA', '附件2文件格式不正确', AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
                audit_list.append(
                    [str(bill_number), '用电量', '(' + str(data['es_number']) + ')' + str(data['electricity_consumption']),
                     '', '0', 'RPA', '附件2文件格式不正确', AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5',
                     ''])
                audit_list.append(
                    [str(bill_number), '电损电量', '(' + str(data['es_number']) + ')' + str(data['electricity_loss']), '',
                     '0', 'RPA', '附件2文件格式不正确', AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
    elif not file_flag2:
        audit_list.append([str(bill_number), '报账点名称', str(rp_name), '', '0', 'RPA', '附件2电力明细清单不存在', '', '5', ''])
        audit_list.append(
            [str(bill_number), '缴费期', str(rp_payment_start_time) + ',' + str(rp_payment_end_time), '', '0', 'RPA',
             '附件2电力明细清单不存在', '', '5', ''])
        if whether_execute == False:
            audit_list.append(
                [str(bill_number), '实际报账金额', str(payment_electric_info_actual_reimbursement_amount), '', '0', 'RPA',
                 '附件2电力明细清单不存在', '', '5', ''])
            audit_list.append(
                [str(bill_number), '本期读数', str(current_reading), '', '0', 'RPA', '附件2电力明细清单不存在', '', '5', ''])
            audit_list.append(
                [str(bill_number), '电费单价', str(electricity_price), '', '0', 'RPA', '附件2电力明细清单不存在', '', '5', ''])
            audit_list.append(
                [str(bill_number), '用电量', str(electricity_consumption), '', '0', 'RPA', '附件2电力明细清单不存在', '', '5', ''])
            audit_list.append(
                [str(bill_number), '电损电量', str(electricity_loss), '', '0', 'RPA', '附件2电力明细清单不存在', '', '5', ''])
        else:
            for data in payment_detail_info_data:
                audit_list.append(
                    [str(bill_number), '实际报账金额',
                     '(' + str(data['es_number']) + ')' + str(payment_electric_info_actual_reimbursement_amount), '',
                     '0', 'RPA', '附件2电力明细清单不存在', '', '5', ''])
                audit_list.append(
                    [str(bill_number), '本期读数', '(' + str(data['es_number']) + ')' + str(data['current_reading']), '',
                     '0', 'RPA', '附件2电力明细清单不存在', '',
                     '5', ''])
                audit_list.append(
                    [str(bill_number), '电费单价', '(' + str(data['es_number']) + ')' + str(data['electricity_price']), '',
                     '0', 'RPA', '附件2电力明细清单不存在', '',
                     '5', ''])
                audit_list.append(
                    [str(bill_number), '用电量', '(' + str(data['es_number']) + ')' + str(data['electricity_consumption']),
                     '', '0', 'RPA', '附件2电力明细清单不存在',
                     '', '5', ''])
                audit_list.append(
                    [str(bill_number), '电损电量', '(' + str(data['es_number']) + ')' + str(data['electricity_loss']), '',
                     '0', 'RPA', '附件2电力明细清单不存在', '',
                     '5', ''])
    else:
        audit_list.append(
            [str(bill_number), '报账点名称', str(rp_name), '', '0', 'RPA', '识别失败', '', '5', ''])
        audit_list.append(
            [str(bill_number), '缴费期', str(rp_payment_start_time) + ',' + str(rp_payment_end_time), '', '0',
             'RPA', '识别失败', '', '5', ''])
        if whether_execute == False:
            audit_list.append(
                [str(bill_number), '实际报账金额', str(payment_electric_info_actual_reimbursement_amount), '', '0',
                 'RPA', '识别失败', '', '5', ''])
            audit_list.append(
                [str(bill_number), '本期读数', str(current_reading), '', '0', 'RPA', '识别失败', '', '5', ''])
            audit_list.append(
                [str(bill_number), '电费单价', str(electricity_price), '', '0', 'RPA', '识别失败', '', '5', ''])
            audit_list.append(
                [str(bill_number), '用电量', str(electricity_consumption), '', '0', 'RPA', '识别失败', '', '5', ''])
            audit_list.append(
                [str(bill_number), '电损电量', str(electricity_loss), '', '0', 'RPA', '识别失败', '', '5', ''])
        else:
            for data in payment_detail_info_data:
                audit_list.append(
                    [str(bill_number), '实际报账金额',
                     '(' + str(data['es_number']) + ')' + str(payment_electric_info_actual_reimbursement_amount), '',
                     '0',
                     'RPA', '识别失败', '', '5', ''])
                audit_list.append(
                    [str(bill_number), '本期读数', '(' + str(data['es_number']) + ')' + str(data['current_reading']), '',
                     '0', 'RPA', '识别失败', '', '5', ''])
                audit_list.append(
                    [str(bill_number), '电费单价', '(' + str(data['es_number']) + ')' + str(data['electricity_price']), '',
                     '0', 'RPA', '识别失败', '', '5', ''])
                audit_list.append(
                    [str(bill_number), '用电量', '(' + str(data['es_number']) + ')' + str(data['electricity_consumption']),
                     '', '0', 'RPA', '识别失败', '', '5',
                     ''])
                audit_list.append(
                    [str(bill_number), '电损电量', '(' + str(data['es_number']) + ')' + str(data['electricity_loss']), '',
                     '0', 'RPA', '识别失败', '', '5', ''])
        # 规则五：页面【电费缴费明细信息】-【本次实际分摊比例】与附件3的【报账点名称】的【移动】（分摊比例）
        # ----   不一致后动作：【审核状态】-【不通过】，备注：系统中录入的分摊比例与附件不一致
        # ----   自维电费报账点不一致后动作：【审核状态】-【不通过】，备注：系统中录入的分摊比例不正确
        if whether_execute == False:
            try:
                if '附件3' in rar_file:
                    auditResult.auditStatus = '审核中'  # 返回稽核结果为转人工
                    audit_list.append(
                        [str(bill_number), '分摊比例', str(current_share_ratio), '', '0', 'RPA', '附件3文件格式不正确',
                         AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件3'), '5', ''])
                else:
                    if not file_flag3:
                        auditResult.auditStatus = '审核中'  # 返回稽核结果为转人工
                        audit_list.append(
                            [str(bill_number), '分摊比例', str(current_share_ratio), '', '0', 'RPA', '附件3分摊比例不存在', '',
                             '5', ''])
                    else:
                        att_3_name = all_file['附件3']
                        rpa_split_ratio_tablename = 'rpa_ocr_split_ratio'  # RPA分割比例记录表
                        rpa_split_ratio_sql = """SELECT * FROM """ + rpa_split_ratio_tablename + """ WHERE affixx_name='""" + att_3_name + """' AND door_no='""" + es_number + """'"""
                        rpa_split_ratio_data = PyMysql().get_db_data(rpa_split_ratio_sql)
                        if not rpa_split_ratio_data and len(rpa_split_ratio_data) == 0:
                            auditResult.auditStatus = '审核中'  # 返回稽核结果为转人工
                            audit_list.append(
                                [str(bill_number), '分摊比例', str(current_share_ratio), '', '0', 'RPA', '识别失败',
                                 AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件3'), '4', ''])
                        else:
                            yidong_split_ratio = str(rpa_split_ratio_data[0]['split_ratio']).strip().replace('%',
                                                                                                             '')  # 移动分割比例
                            # if float(str(yidong_split_ratio).strip().replace('%', '')) != float(str(current_share_ratio).strip().replace('%', '')):
                            if str(current_share_ratio).strip().replace('%', '') in str(
                                    yidong_split_ratio).strip().replace('%', '') or str(
                                yidong_split_ratio).strip().replace('%', '') in str(
                                current_share_ratio).strip().replace('%', ''):
                                audit_list.append(
                                    [str(bill_number), '分摊比例', str(current_share_ratio), str(yidong_split_ratio),
                                     '1',
                                     'RPA', '合格', AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件3'), '4',
                                     ''])
                            else:
                                auditResult.auditStatus = '不通过'  # 返回稽核结果为不通过
                                audit_refused_type['信息与明细不符'] = 0
                                audit_list.append(
                                    [str(bill_number), '分摊比例', str(current_share_ratio), str(yidong_split_ratio),
                                     '0',
                                     'RPA', '系统中录入的分摊比例与附件不一致',
                                     AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件3'),
                                     '4', ''])
            except Exception as e:
                # print(e)
                audit_list.append(
                    [str(bill_number), '分摊比例', str(current_share_ratio), str(yidong_split_ratio), '0', 'RPA',
                     'RPA处理异常', AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件3'), '4', ''])
                auditResult.auditStatus = '审核中'  # 转人工
        else:
            for data in payment_detail_info_data:
                try:
                    if '附件3' in rar_file:
                        auditResult.auditStatus = '审核中'  # 返回稽核结果为转人工
                        audit_list.append(
                            [str(bill_number), '分摊比例', '(' + str(data['es_number']) + ')' + str(current_share_ratio),
                             '', '0', 'RPA',
                             '附件3文件格式不正确',
                             AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件3'), '5', ''])
                    else:
                        if not file_flag3:
                            auditResult.auditStatus = '审核中'  # 返回稽核结果为转人工
                            audit_list.append(
                                [str(bill_number), '分摊比例',
                                 '(' + str(data['es_number']) + ')' + str(current_share_ratio), '', '0', 'RPA',
                                 '附件3分摊比例不存在', '',
                                 '5', ''])
                        else:
                            att_3_name = all_file['附件3']
                            rpa_split_ratio_tablename = 'rpa_ocr_split_ratio'  # RPA分割比例记录表
                            rpa_split_ratio_sql = """SELECT * FROM """ + rpa_split_ratio_tablename + """ WHERE affixx_name='""" + att_3_name + """' AND door_no='""" + str(
                                data['es_number']) + """'"""
                            rpa_split_ratio_data = PyMysql().get_db_data(rpa_split_ratio_sql)
                            if not rpa_split_ratio_data and len(rpa_split_ratio_data) == 0:
                                auditResult.auditStatus = '审核中'  # 返回稽核结果为转人工
                                audit_list.append(
                                    [str(bill_number), '分摊比例',
                                     '(' + str(data['es_number']) + ')' + str(current_share_ratio), '', '0', 'RPA',
                                     '识别失败',
                                     AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件3'), '4', ''])
                            else:
                                es_number_row = 0
                                for execute_list_data in execute_list:
                                    if str(execute_list_data[0]) == str(data['es_number']):
                                        es_number_row = execute_list_data[1]
                                yidong_split_ratio = str(
                                    rpa_split_ratio_data[es_number_row]['split_ratio']).strip().replace('%',
                                                                                                        '')  # 移动分割比例
                                # if float(str(yidong_split_ratio).strip().replace('%', '')) != float(str(current_share_ratio).strip().replace('%', '')):
                                if str(current_share_ratio).strip().replace('%', '') in str(
                                        yidong_split_ratio).strip().replace('%', '') or str(
                                    yidong_split_ratio).strip().replace('%', '') in str(
                                    current_share_ratio).strip().replace('%', ''):
                                    audit_list.append(
                                        [str(bill_number), '分摊比例',
                                         '(' + str(data['es_number']) + ')' + str(current_share_ratio),
                                         str(yidong_split_ratio),
                                         '1',
                                         'RPA', '合格', AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件3'),
                                         '4', ''])
                                else:
                                    auditResult.auditStatus = '不通过'  # 返回稽核结果为不通过
                                    audit_refused_type['信息与明细不符'] = 0
                                    audit_list.append(
                                        [str(bill_number), '分摊比例',
                                         '(' + str(data['es_number']) + ')' + str(current_share_ratio),
                                         str(yidong_split_ratio),
                                         '0',
                                         'RPA', '系统中录入的分摊比例与附件不一致',
                                         AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件3'),
                                         '4', ''])
                except Exception as e:
                    # print(e)
                    audit_list.append(
                        [str(bill_number), '分摊比例', '(' + str(data['es_number']) + ')' + str(current_share_ratio),
                         str(yidong_split_ratio), '0',
                         'RPA',
                         'RPA处理异常', AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件3'), '4', ''])
                    auditResult.auditStatus = '审核中'  # 转人工
    return audit_list, auditResult,audit_refused_type


"""
    【综合票据稽核】核销单- 数据稽核
"""
def audit_rule_verification_data(audit_list, auditResult, bill_number, rar_file, whether_execute, audit_refused_type,result,
                     file_flag2, page_rp_name, affix_list_from_db,ocr_uname,
                     page_actual_total_amount, ocr_ele_charge, verification_detail_info_data,page_current_reading,ocr_now_display_num,
                     data,page_electricity_price,ocr_ele_price, page_electricity_consumption,page_last_reading,ocr_last_display_num,
                     ocr_ele_loss,page_current_share_ratio,bill_table_data_list, ocr_total_power,
                     page_electricity_loss,page_start_time, page_end_time,ocr_start_date, ocr_end_date,es_magnification):


    # 规则1：页面【电费核销明细信息】-【电表户号】查找附件二【用户编号】的【客户地址】与对应的页面【报账点名称】作匹对，在明细表识别结果上再加列【报账点名称】
    # ---   不一致：页面【审核备注】：报账点名称与电力清单中名称不一致。
    audit_list = AuditRuleWriteOff.audit_rule_one(audit_list, bill_number, rar_file,
                                                  page_rp_name, affix_list_from_db, ocr_uname, file_flag2)
    # 规则4：页面【实际总金额】与附件2（以户号为依据）的金额判断，必须完全一致
    # ---   不一致后动作：【审核状态】-【不通过】，备注：【实际报账金额】与【电费明细】不一致
    auditResult, audit_list, audit_refused_type = AuditRuleWriteOff.audit_rule_four(auditResult, audit_list,
                                                                                    audit_refused_type, bill_number,
                                                                                    whether_execute, rar_file,
                                                                                    page_actual_total_amount,
                                                                                    affix_list_from_db, file_flag2,
                                                                                    ocr_ele_charge,
                                                                                    verification_detail_info_data, data,
                                                                                    bill_table_data_list)
    # 规则7：页面【电表核销明细信息】-【本期读数（度）】与附件2根据页面【电表缴费明细信息】-【户号】查找对应的【本期指示】/【本月】等等
    # ---   不一致后动作：【审核状态】-【不通过】，备注：本期读数与电费明细不一致
    audit_list, auditResult, audit_refused_type = AuditRuleWriteOff.audit_rule_seven(audit_list, auditResult,
                                                                                     audit_refused_type,
                                                                                     whether_execute, rar_file,
                                                                                     affix_list_from_db, bill_number,
                                                                                     file_flag2, page_current_reading,
                                                                                     ocr_now_display_num,
                                                                                     verification_detail_info_data,
                                                                                     bill_table_data_list)
    # 规则8：页面【电表核销明细信息】-【电费单价（元/度）】与附件2根据页面【电表缴费明细信息】-【户号】查找对应的【电价】/【电费信息】之和等等??????????
    # ---   不一致后动作：【审核状态】-【不通过】，备注：电费单价与电费明细不一致
    auditResult, audit_list, audit_refused_type = AuditRuleWriteOff.audit_rule_eight(auditResult, audit_list,
                                                                                     audit_refused_type,
                                                                                     whether_execute, rar_file,
                                                                                     bill_number,
                                                                                     file_flag2,
                                                                                     verification_detail_info_data,
                                                                                     page_electricity_price,
                                                                                     ocr_ele_price,
                                                                                     affix_list_from_db,
                                                                                     bill_table_data_list)
    """
        上期读数
    """
    audit_list, auditResult, audit_refused_type = AuditRuleWriteOff.audit_rule_lastReding(audit_list, auditResult, audit_refused_type, whether_execute, rar_file, affix_list_from_db,
                          bill_number,
                          file_flag2, page_last_reading, ocr_last_display_num, verification_detail_info_data,
                          bill_table_data_list)


    # 规则9：如果【本期读数】判断通过：页面【电表缴费明细信息】-【用电量（度）】=【本期读数（度）】减去【上期读数（度）】，此条规则需完全一致。
    # ---   如果附件2无【本期读数】：页面【电表缴费明细信息】-【用电量（度）】+（【电损电量】/【本次实际分摊比例】）=附件2根据页面【电表缴费明细信息】-【户号】查找对应的【总结算电量】，
    # ---   或者如果附件2无【本期读数】：页面【电表缴费明细信息】-【用电量（度）】=附件2根据页面【电表缴费明细信息】-【户号】查找对应的【电量】。具体是那种情况，需在票据学习时区分附件2中电量是否包括电损。
    # ---   后面2条规则四舍五入匹配，相差±1度均可判断通过。
    # ---   不一致后动作：【审核状态】-【不通过】，备注：用电量与电费明细不一致
    # ---   备注：如果页面【电表核销明细信息】-【电费单价（元/度）】存在多条只需核对用电量非0的，核对单据存在一对一或多对一情况。?????????????????
    audit_list, auditResult, audit_refused_type = AuditRuleWriteOff.audir_rule_nine(audit_list, auditResult,
                                                                                    audit_refused_type, rar_file,
                                                                                    whether_execute, bill_number,page_electricity_loss,
                                                                                    affix_list_from_db,
                                                                                    page_current_reading,
                                                                                    page_last_reading,
                                                                                    verification_detail_info_data,
                                                                                    file_flag2,
                                                                                    page_electricity_consumption,
                                                                                    ocr_last_display_num,
                                                                                    ocr_now_display_num,
                                                                                    ocr_ele_loss, es_magnification,
                                                                                    page_current_share_ratio,
                                                                                    ocr_total_power,
                                                                                    bill_table_data_list)
    # 规则10：前提：本次分摊比例稽核正确：页面【电表核销明细信息】-【电损电量（度）】与附件2（有单独列出电损电量）：页面【电表核销明细信息】-【电损电量（度）】=【本次实际分摊比例】*附件2的【电损值】；
    # ---    如附件2中同时有总电量（包括电损）、上期读数和本期读数，则页面【电表核销明细信息】-【电损电量（度）】=【本次实际分摊比例】*（附件2的【总电量】-附件2【本期读数-上期读数】）。
    # ---    如果附件2（不符合上面情况或无单独列出电损电量）直接跳过。具体是那种情况，需在票据学习时区分附件2中总电量是否包括电损。四舍五入匹配，相差±1度均可判断通过。
    # ---    不一致后动作：【审核状态】-【不通过】，备注：电损电量与电费明细不一致
    auditResult, audit_list, audit_refused_type, result = AuditRuleWriteOff.audit_rule_ten(auditResult, audit_list,
                                                                                           whether_execute, rar_file,
                                                                                           bill_number,
                                                                                           affix_list_from_db,
                                                                                           audit_refused_type, result,
                                                                                           ocr_total_power,
                                                                                           ocr_last_display_num,es_magnification,
                                                                                           file_flag2,
                                                                                           verification_detail_info_data,
                                                                                           page_electricity_loss,
                                                                                           ocr_ele_loss,
                                                                                           page_current_share_ratio,
                                                                                           ocr_now_display_num,
                                                                                           bill_table_data_list)
    # 规则11：页面【报账点核销信息】的【核销期始】和【核销期终】=附件2根据页面【电表缴费明细信息】-【户号】查找对应的【时间】/【起止时间】，如果附件2没有时间字段不作比对
    # ---    不一致后动作：【审核状态】-【不通过】，备注：缴费期始/终与电费明细不一致
    auditResult, audit_list, audit_refused_type = AuditRuleWriteOff.audit_rule_eleven(auditResult, audit_list,
                                                                                      audit_refused_type, bill_number,
                                                                                      whether_execute, rar_file,
                                                                                      page_start_time, page_end_time,
                                                                                      affix_list_from_db,
                                                                                      ocr_start_date, ocr_end_date,
                                                                                      bill_table_data_list,
                                                                                      verification_detail_info_data,
                                                                                      file_flag2)
    return auditResult, audit_list, audit_refused_type, result


"""
    【综合票据稽核】核销单- 页面稽核
"""
def audit_rule_verification_page(auditResult, audit_list, bill_number,audit_refused_type,
                                 page_actual_nae_taxsad,page_actual_ef_tariff,page_amount_including_tax,page_actual_total_amount,
                                 page_actual_verification_amount,page_payment_amount,whether_execute,
                                 verification_detail_info_data, page_current_share_ratio, page_es_number,
                                 page_actual_reimbursement_amount,page_actual_total_pc,
                                 page_electricity_loss, page_share_degrees,
                                 all_file, affix_list_from_db, floder_path, verification_benchmark_info_data,rp_code):
    # 规则2：页面【报账点缴费信息】-【实际不含税电费金额】+【实际电费税金】+【其他费用】的【含税金额】=【实际总金额】
    # ---   不一致后动作：【审核状态】-【不通过】，备注：【实际不含税电费金额】+【实际电费税金】+【其他费用】的【含税金额】不等于【实际总金额】
    auditResult, audit_list, audit_refused_type = AuditRuleWriteOff.audit_rule_two(auditResult, audit_list,
                                                                                   audit_refused_type, bill_number,
                                                                                   page_actual_nae_taxsad,
                                                                                   page_actual_ef_tariff,
                                                                                   page_amount_including_tax,
                                                                                   page_actual_total_amount)
    # 规则3：页面【其他费】-【实际总金额】= 【实际核销金额】 +  【支付金额】
    # ---   不一致后动作：【审核状态】-【不通过】，备注：【实际总金额】不等于【实际核销金额】与【支付金额】之和
    auditResult, audit_list, audit_refused_type = AuditRuleWriteOff.audit_rule_three(auditResult, audit_list,
                                                                                     audit_refused_type, bill_number,
                                                                                     page_actual_total_amount,
                                                                                     page_actual_verification_amount,
                                                                                     page_payment_amount)
    # 规则5：页面【缴费标杆信息】-【标杆类型】（9类）-其中一类高于阈值（后期配置）为异常。目前为五类，预留4类，分别为智能电表标杆和动环负载标杆。
    # ---   异常后动作：检查是否存在附件5；如果附件5为单站，直接跳过（只需判断是否存在附件5）；如果附件5为汇总，进入附件6（excel）查找是否该户号；
    # ---   如果附件存在转人工（把所有的核对点都做了），如果附件不存在：【审核状态】-【不通过】，备注：请上传超标情况分析报告
    auditResult, audit_list = AuditRuleWriteOff.audit_rule_five(auditResult, audit_list, bill_number,
                                                                verification_benchmark_info_data, all_file, floder_path,
                                                                affix_list_from_db, rp_code)

    # 规则6：页面【电表核销明细信息】-【本次实际分摊比例】为100%即为通过
    # ---   不一致后动作：【审核状态】-【不通过】，备注：系统中录入的分摊比例不正确
    auditResult, audit_list, audit_refused_type = AuditRuleWriteOff.audit_rule_six(auditResult, audit_list,
                                                                                   audit_refused_type, bill_number,
                                                                                   whether_execute,
                                                                                   affix_list_from_db,
                                                                                   verification_detail_info_data,
                                                                                   page_current_share_ratio)

    # 规则12：增加“平均电费单价”展示，计算公式为：平均电费单价=【实际报账金额】/【实际总耗电量】，如此值小于等于0.3或者大于等于0.7，转人工稽核。其他稽核条件均需识别判断展示。
    # ---    备注：均电费单价小于等于0.3/大于等于0.7
    auditResult, audit_list = AuditRuleWriteOff.audit_rule_twelve(auditResult, audit_list, bill_number,
                                                                  page_actual_reimbursement_amount,
                                                                  page_actual_total_pc)
    # 规则13：增加“电损电量占比”展示，计算公式为：电损电量占比=【电损电量(度)】/【分摊后度数(度)】，如此值大于等于10%，转人工稽核。其他稽核条件均需识别判断展示。
    # ---    备注：电损电量占比大于等于10%
    auditResult, audit_list = AuditRuleWriteOff.audit_rule_thirteen(auditResult, audit_list, bill_number,
                                                                    whether_execute,
                                                                    page_electricity_loss, page_share_degrees,
                                                                        verification_detail_info_data)
    return auditResult, audit_list, audit_refused_type

"""
    缴费单-查找不到附件数据的稽核处理：
"""
def audit_rule_verification_no_data(auditResult,audit_list,rar_file,bill_number,affix_list_from_db,whether_execute,
                                    page_rp_name,page_start_time,page_end_time,page_actual_total_amount,
                                    page_current_reading,page_electricity_price,page_electricity_consumption,page_electricity_loss,
                                    verification_detail_info_data,file_flag2):
    auditResult.auditStatus = '审核中'  # 返回稽核结果为转人工
    if '附件2' in rar_file:
        audit_list.append([str(bill_number), '报账点名称', str(page_rp_name), '', '0', 'RPA', '附件2文件格式不正确',
                           AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
        audit_list.append(
            [str(bill_number), '核销期', str(page_start_time) + ',' + str(page_end_time), '', '0', 'RPA', '附件2文件格式不正确',
             AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])

        if whether_execute == False:
            audit_list.append(
                [str(bill_number), '实际总金额', str(page_actual_total_amount), '', '0', 'RPA', '附件2文件格式不正确',
                 AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
            audit_list.append(
                [str(bill_number), '本期读数', str(page_current_reading), '', '0', 'RPA', '附件2文件格式不正确',
                 AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
            audit_list.append(
                [str(bill_number), '电费单价', str(page_electricity_price), '', '0', 'RPA', '附件2文件格式不正确',
                 AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
            audit_list.append(
                [str(bill_number), '用电量', str(page_electricity_consumption), '', '0', 'RPA', '附件2文件格式不正确',
                 AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
            audit_list.append(
                [str(bill_number), '电损电量', str(page_electricity_loss), '', '0', 'RPA', '附件2文件格式不正确',
                 AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
        else:
            for data in verification_detail_info_data:
                audit_list.append(
                    [str(bill_number), '实际总金额', '【' + str(data['es_number']) + '】' + str(page_actual_total_amount), '',
                     '0', 'RPA', '附件2文件格式不正确', AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
                audit_list.append(
                    [str(bill_number), '本期读数', '【' + str(data['es_number']) + '】' + str(data['current_reading']), '',
                     '0', 'RPA', '附件2文件格式不正确', AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
                audit_list.append(
                    [str(bill_number), '电费单价', '【' + str(data['es_number']) + '】' + str(data['electricity_price']), '',
                     '0', 'RPA', '附件2文件格式不正确', AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
                audit_list.append(
                    [str(bill_number), '用电量', '【' + str(data['es_number']) + '】' + str(data['electricity_consumption']),
                     '', '0', 'RPA', '附件2文件格式不正确', AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5',
                     ''])
                audit_list.append(
                    [str(bill_number), '电损电量', '【' + str(data['es_number']) + '】' + str(data['electricity_loss']), '',
                     '0', 'RPA', '附件2文件格式不正确', AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])

    elif not file_flag2:
        audit_list.append([str(bill_number), '报账点名称', str(page_rp_name), '', '0', 'RPA', '附件2电力明细清单不存在',
                           AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
        audit_list.append(
            [str(bill_number), '核销期', str(page_start_time) + ',' + str(page_end_time), '', '0', 'RPA', '附件2电力明细清单不存在',
             AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])

        if whether_execute == False:
            audit_list.append(
                [str(bill_number), '实际总金额', str(page_actual_total_amount), '', '0', 'RPA', '附件2电力明细清单不存在',
                 AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
            audit_list.append(
                [str(bill_number), '本期读数', str(page_current_reading), '', '0', 'RPA', '附件2电力明细清单不存在',
                 AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
            audit_list.append(
                [str(bill_number), '电费单价', str(page_electricity_price), '', '0', 'RPA', '附件2电力明细清单不存在',
                 AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
            audit_list.append(
                [str(bill_number), '用电量', str(page_electricity_consumption), '', '0', 'RPA', '附件2电力明细清单不存在',
                 AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
            audit_list.append(
                [str(bill_number), '电损电量', str(page_electricity_loss), '', '0', 'RPA', '附件2电力明细清单不存在',
                 AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
        else:
            for data in verification_detail_info_data:
                audit_list.append(
                    [str(bill_number), '实际总金额', '【' + str(data['es_number']) + '】' + str(page_actual_total_amount), '',
                     '0', 'RPA', '附件2电力明细清单不存在',
                     AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
                audit_list.append(
                    [str(bill_number), '本期读数', '【' + str(data['es_number']) + '】' + str(data['current_reading']), '',
                     '0', 'RPA', '附件2电力明细清单不存在',
                     AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
                audit_list.append(
                    [str(bill_number), '电费单价', '【' + str(data['es_number']) + '】' + str(data['electricity_price']), '',
                     '0', 'RPA', '附件2电力明细清单不存在',
                     AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
                audit_list.append(
                    [str(bill_number), '用电量', '【' + str(data['es_number']) + '】' + str(data['electricity_consumption']),
                     '', '0', 'RPA', '附件2电力明细清单不存在',
                     AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
                audit_list.append(
                    [str(bill_number), '电损电量', '【' + str(data['es_number']) + '】' + str(data['electricity_loss']), '',
                     '0', 'RPA', '附件2电力明细清单不存在',
                     AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])


    else:
        audit_list.append([str(bill_number), '报账点名称', str(page_rp_name), '', '0', 'RPA', '识别失败',
                           AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
        audit_list.append(
            [str(bill_number), '核销期', str(page_start_time) + ',' + str(page_end_time), '', '0', 'RPA',
             '识别失败', AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])

        if whether_execute == False:
            audit_list.append(
                [str(bill_number), '实际总金额', str(page_actual_total_amount), '', '0', 'RPA', '识别失败',
                 AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
            audit_list.append(
                [str(bill_number), '本期读数', str(page_current_reading), '', '0', 'RPA', '识别失败',
                 AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
            audit_list.append(
                [str(bill_number), '电费单价', str(page_electricity_price), '', '0', 'RPA', '识别失败',
                 AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
            audit_list.append(
                [str(bill_number), '用电量', str(page_electricity_consumption), '', '0', 'RPA', '识别失败',
                 AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
            audit_list.append([str(bill_number), '电损电量', str(page_electricity_loss), '', '0', 'RPA', '识别失败',
                               AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
        else:
            for data in verification_detail_info_data:
                audit_list.append(
                    [str(bill_number), '实际总金额', '【' + str(data['es_number']) + '】' + str(page_actual_total_amount), '',
                     '0', 'RPA', '识别失败',
                     AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
                audit_list.append(
                    [str(bill_number), '本期读数', '【' + str(data['es_number']) + '】' + str(data['current_reading']), '',
                     '0', 'RPA', '识别失败',
                     AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
                audit_list.append(
                    [str(bill_number), '电费单价', '【' + str(data['es_number']) + '】' + str(data['electricity_price']), '',
                     '0', 'RPA', '识别失败',
                     AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
                audit_list.append(
                    [str(bill_number), '用电量', '【' + str(data['es_number']) + '】' + str(data['electricity_consumption']),
                     '', '0', 'RPA', '识别失败',
                     AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
                audit_list.append(
                    [str(bill_number), '电损电量', '【' + str(data['es_number']) + '】' + str(data['electricity_loss']), '',
                     '0', 'RPA', '识别失败',
                     AffixUtils.get_affix_url_with_name(affix_list_from_db, '附件2'), '5', ''])
    return auditResult,audit_list